package exportimporterentities;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import autoservice.api.entitites.IGarage;
import autoservice.api.entitites.IMaster;
import autoservice.api.entitites.IOrder;
import autoservice.api.exportimportentities.IExportImportEntities;
import autoservice.api.messages.Messager;

public class ExportImportEntities implements IExportImportEntities {

	private ArrayList<String> arrayMessanger = new ArrayList<String>();
	

	private Export exporter = new Export();
	private Import importer = new Import();

	public void ExportGarages(List<IGarage> garageList,String path) {
		arrayMessanger.clear();
		try {
			exporter.exportGarage(garageList,path);
			arrayMessanger.add(Messager.EXPORT);
		} catch (RuntimeException e) {
			arrayMessanger.add(e.getMessage());
		}
		
	}

	public void ExportMasters(List<IMaster> masterList,String path) {
		arrayMessanger.clear();
		try {
			exporter.exportMaster(masterList,path);
			arrayMessanger.add(Messager.EXPORT);
		} catch (RuntimeException e) {
			arrayMessanger.add(e.getMessage());
		}
		
	}

	public void ExportOrders(List<IOrder> orderList,String path) {
		arrayMessanger.clear();
		try {
			exporter.exportOrder(orderList,path);
			arrayMessanger.add(Messager.EXPORT);
		} catch (RuntimeException e) {
			arrayMessanger.add(e.getMessage());
		}
		
		

	}

	public ArrayList<IGarage> ImportGarages(String path) throws FileNotFoundException {
		
			return importer.getGarages(path);
		
	}

	public ArrayList<IMaster> ImportMasters(String path) throws FileNotFoundException {
		
		return importer.getMasters(path);
			
		
	}

	public ArrayList<IOrder> ImportOrders(String orderPath,String masterPath, String garagePath) throws FileNotFoundException {
		return importer.getOrders(orderPath, masterPath, garagePath);
			
	}

}
